import re,json,requests
def doWork():
    num = input("input chu ku dan number: ")
    customer = input("input customer name: ")
    address = input("input customer address: ")
    tel = input("input customer tel: ")
    rows = list()
    while True:
        row = input("input chu ku huo wu like name price total(x exit): ")
        if row in ["x","q","X","Q",""]:
            break
        pattern = r"(?P<name>[^#@/]+)[#@/](?P<price>[^#@/]+)[#@/](?P<total>[^#@/]+)"
        match = re.search(pattern,row)
        if match:
            rows.append({"name":match.group("name"),"price":match.group("price"),"total":match.group("total")})
    details = json.dumps(rows)
    # save record
    record = ["YHDN"+num.zfill(8),customer,address,tel,details]
    requests.post(url="http://yhdn.cn:5000/chuku/add",json={"record":record})
 

if __name__ == "__main__":
    doWork()